$(document).ready(function(){
	scrollToSection()
	changeNavbar();
});

function scrollToSection(){
    $('a[href*=#]:not([href=#])').click(function() {
        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') || location.hostname == this.hostname) {

            var target = $(this.hash);
            target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
            if (target.length) {
                $('html,body').animate({
                    scrollTop: target.offset().top
                }, 1000);
                return false;
            }
        }
    });
}

function changeNavbar(){
	$('ul.nav > li > a').click(function (e) {
		e.preventDefault();
		$('ul.nav > li').removeClass("sg-active");
        $(this).parent().toggleClass("sg-active");           
    });

    $("a.navbar-brand").click(function (e) {
		e.preventDefault();
		$('ul.nav > li').removeClass("sg-active");
        $('ul.nav > li:nth-child(2)').toggleClass("sg-active");           
    });
}